<template>
  <div>
    <h1>添加等级</h1>
    <table class="table table-bordered">
      <tbody>
        <tr>
          <td>名称</td>
          <td>
            <input type="text" v-model="info.dname" />
          </td>
        </tr>
        <tr>
          <td>权益</td>
          <td><input type="text" v-model="info.dquan" /></td>
        </tr>
        <tr>
          <td></td>
          <td><input type="button" value="添加" @click="add" /></td>
        </tr>
      </tbody>
    </table>
  </div>
</template>

<script setup lang="ts">
import { ref, onMounted, reactive } from "vue";
import axios from "axios";
import { useRoute, useRouter } from "vue-router";
let info: any = reactive({
  dname: "",
  dtype: 1,
  dquan: "",
});

const add = () => {
  axios({
    url: "/api/User/AddDeng",
    method: "post",
    data: info,
  }).then((res) => {
    console.log(res);
    if (res.data == -1) {
      alert("昵称重复");
      return;
    }
    if (res.data > 0) {
      alert("添加成功");
      return;
    } else {
      alert("添加失败");
      return;
    }
  });
};
</script>

<style scoped></style>
